package javase2.day02;

import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;

/**
 * File API ������ʾ
 *
 */
public class Demo5 {
  public static void main(String[] args)
     throws IOException {
    File dir = new File(".");
    System.out.println(dir.getCanonicalPath());//pwd
    File sub = new File("sub/demo");
    if(! sub.exists()){
      sub.mkdirs();//����ϵ���ļ���
    }
    File file = new File(sub, "demo.txt");
    if(! file.exists()){
      file.createNewFile();//�������ļ�
    }
    System.out.println(file.getName()+":"+file.isFile());
    long time = file.lastModified();
    SimpleDateFormat fmt = 
      new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
    System.out.println(fmt.format(time));
    System.out.println(sub.getName()+":"+sub.isFile());
    System.out.println(sub.getName()+":"+sub.isDirectory()); 
    File bak = new File(sub, "bak.txt");
    file.renameTo(bak);//file ��������Ϊ�� bak
  }
}










